From 69a6f6d0748d55d21e25cfb942c93d2317c4af15 Mon Sep 17 00:00:00 2001 From: Alex Williamson Date: Tue, 20 Nov 2007 09:21:27 -0700 Subject: [PATCH] [IA64] vti save-restore: save/restore opt_feature status Make hvm domain save/restore support opt_feature. Signed-off-by: Isaku Yamahata --- xen/arch/ia64/vmx/mmio.c | 72 +++++++++++++++++++++++++ xen/include/public/arch-ia64/hvm/save.h | 32 +++++++---- 2 files changed, 93 insertions(+), 11 deletions(-) diff --git a/xen/arch/ia64/vmx/mmio.c b/xen/arch/ia64/vmx/mmio.c index 0c0b49c503..bf5223ce9a 100644 --- a/xen/arch/ia64/vmx/mmio.c +++ b/xen/arch/ia64/vmx/mmio.c @@ -37,6 +37,8 @@ #include #include #include +#include +#include #define HVM_BUFFERED_IO_RANGE_NR 1 @@ -261,6 +263,76 @@ static inline void set_os_type(VCPU *v, u64 type) } } +static void __vmx_identity_mapping_save(int on, + const struct identity_mapping* im, + struct hvm_hw_ia64_identity_mapping *im_save) +{ + im_save->on = !!on; + if (!on) { + im_save->pgprot = 0; + im_save->key = 0; + } else { + im_save->pgprot = im->pgprot; + im_save->key = im->key; + } +} + +static int vmx_identity_mappings_save(struct domain *d, + hvm_domain_context_t *h) +{ + const struct opt_feature *optf = &d->arch.opt_feature; + struct hvm_hw_ia64_identity_mappings im_save; + + __vmx_identity_mapping_save(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG4, + &optf->im_reg4, &im_save.im_reg4); + __vmx_identity_mapping_save(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG5, + &optf->im_reg5, &im_save.im_reg5); + __vmx_identity_mapping_save(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG7, + &optf->im_reg7, &im_save.im_reg7); + + return hvm_save_entry(OPT_FEATURE_IDENTITY_MAPPINGS, 0, h, &im_save); +} + +static int __vmx_identity_mapping_load(struct domain *d, unsigned long cmd, + const struct hvm_hw_ia64_identity_mapping *im_load) +{ + struct xen_ia64_opt_feature optf; + + optf.cmd = cmd; + optf.on = im_load->on; + optf.pgprot = im_load->pgprot; + optf.key = im_load->key; + + return domain_opt_feature(d, &optf); +} + +static int vmx_identity_mappings_load(struct domain *d, + hvm_domain_context_t *h) +{ + struct hvm_hw_ia64_identity_mappings im_load; + int rc; + + if (hvm_load_entry(OPT_FEATURE_IDENTITY_MAPPINGS, h, &im_load)) + return -EINVAL; + + rc = __vmx_identity_mapping_load(d, XEN_IA64_OPTF_IDENT_MAP_REG4, + &im_load.im_reg4); + if (rc) + return rc; + rc = __vmx_identity_mapping_load(d, XEN_IA64_OPTF_IDENT_MAP_REG5, + &im_load.im_reg5); + if (rc) + return rc; + rc = __vmx_identity_mapping_load(d, XEN_IA64_OPTF_IDENT_MAP_REG7, + &im_load.im_reg7); + + return rc; +} + +HVM_REGISTER_SAVE_RESTORE(OPT_FEATURE_IDENTITY_MAPPINGS, + vmx_identity_mappings_save, + vmx_identity_mappings_load, + 1, HVMSR_PER_DOM); static void legacy_io_access(VCPU *vcpu, u64 pa, u64 *val, size_t s, int dir) { diff --git a/xen/include/public/arch-ia64/hvm/save.h b/xen/include/public/arch-ia64/hvm/save.h index e6d08a1904..eef06b25e2 100644 --- a/xen/include/public/arch-ia64/hvm/save.h +++ b/xen/include/public/arch-ia64/hvm/save.h @@ -162,25 +162,35 @@ struct hvm_hw_ia64_vacpi { }; DECLARE_HVM_SAVE_TYPE(VACPI, 7, struct hvm_hw_ia64_vacpi); // update last_gtime and setup timer of struct vacpi -#endif -#if 0 /* - * guest os type - * XXX Xen guest os specific optimization - * This isn't hvm specific so this should be addressed genericly - * including paravirtualized domain. + * opt_feature: identity mapping of region 4, 5 and 7. + * With the c/s 16396:d2935f9c217f of xen-ia64-devel.hg, + * opt_feature hypercall supports only region 4,5,7 identity mappings. + * structure hvm_hw_ia64_identity_mappings only supports them. + * The new structure, struct hvm_hw_ia64_identity_mappings, is created to + * avoid to keep up with change of the xen/ia64 internal structure, struct + * opt_feature. + * + * If it is enhanced in the future, new structure will be created. */ -struct hvm_hw_ia64_gos { - uint64_t gos_type; +struct hvm_hw_ia64_identity_mapping { + uint64_t on; /* on/off */ + uint64_t pgprot; /* The page protection bit mask of the pte. */ + uint64_t key; /* A protection key. */ +}; + +struct hvm_hw_ia64_identity_mappings { + struct hvm_hw_ia64_identity_mapping im_reg4;/* Region 4 identity mapping */ + struct hvm_hw_ia64_identity_mapping im_reg5;/* Region 5 identity mapping */ + struct hvm_hw_ia64_identity_mapping im_reg7;/* Region 7 identity mapping */ }; -DECLARE_HVM_SAVE_TYPE(GOS_TYPE, 8, struct hvm_hw_ia64_gos); -#endif +DECLARE_HVM_SAVE_TYPE(OPT_FEATURE_IDENTITY_MAPPINGS, 8, struct hvm_hw_ia64_identity_mappings); /* * Largest type-code in use */ -#define HVM_SAVE_CODE_MAX 7 +#define HVM_SAVE_CODE_MAX 8 #endif /* __XEN_PUBLIC_HVM_SAVE_IA64_H__ */ -- 2.30.2